package com.goukakuproject;

import com.leftMenuHelper.Lession;
import com.leftMenuHelper.LessionAdapter;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class GKLeftmenu extends Activity {

	private ListView listViewLeftMenu;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_gkleftmenu);        
        Intent callerIntent=getIntent();
		Bundle packageFromCaller = callerIntent.getBundleExtra("Main");		
		int bai = packageFromCaller.getInt("N");     
		this.setTitle("Trình độ N" + bai);
        loadData(bai);        
        //Toast.makeText(GKLeftmenu.this, bai + "clicked", Toast.LENGTH_SHORT).show();
    }

    private void loadData(final int bai){
    	Lession lessonData[] = new Lession[10];       
        for (int i = 0; i< 10; i++){
        	lessonData[i] =  new Lession(R.drawable.ic_launcher, "Bài " + (i+1));
        }        
         LessionAdapter adapter = new LessionAdapter(this,R.layout.listview_item_row, lessonData);               
         listViewLeftMenu = (ListView)findViewById(R.id.listViewLeftMenu);         
         View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);         
         listViewLeftMenu.addHeaderView(header);        
         listViewLeftMenu.setAdapter(adapter);         
         listViewLeftMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				 Intent myIntent=new Intent(GKLeftmenu.this,GKTabmain.class);		 
				 Bundle bundle=new Bundle();
				 bundle.putInt("N", bai);
				 bundle.putInt("Bai", arg2);
				 myIntent.putExtra("GKLeftmenu", bundle);
				 startActivity(myIntent);
			}
			
		});
    }
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.gkleftmenu, menu);
		return true;
	}

}
